<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>智慧社区后台</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/AdminLTE.min.css">
</head>
<style>
</style>
<body style="padding-bottom: 90px; background-color: #ECF0F5;">
	<div id="app" class="modal-content">
		<div class="modal-body">
			<div class="form-group">
				<label class="control-label">类型名称：</label> <input type="text" class="form-control" v-model="item.name">
			</div>
		</div>
	</div>
</body>
<script src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<!-- layer -->
<script src="${pageContext.request.contextPath}/plugins/layer/2.4/layer.js"></script>
<script src="${pageContext.request.contextPath}/js/ajaxfileupload.js"></script>
<!-- vue -->
<script src="${pageContext.request.contextPath}/js/vue.min.js"></script>
<script>
	var vm = new Vue(
			{
				el : '#app',
				data : {
					item : {
						id : "${map['id']}",
						name : '',
					},
					lock : false,
					index : parent.layer.getFrameIndex(window.name)
				},
				methods : {
					initData : function() {
						var that = this;
						if (that.item.id != '') {
							$
									.ajax({
										url : "${pageContext.request.contextPath}/selectPropertyServiceTypeById",
										type : "post",
										data : {
											id : that.item.id
										},
										dataType : "json",
										success : function(data) {
											that.item = data['goodsType'];
											that.$delete(that.item,
													'createTime');
										}
									})
						}
					},
					insertPersonnel : function() {
						var that = this;
						var phone = /^1\d{10}$/;
						that.lock = true;
						if (that.item.name == '') {
							layer.alert("请填写类型名称!");
							that.lock = false;
							return;
						}
						// 				if (phone.test(that.item.phone) == false) {
						// 					layer.alert("手机输入不合法!");
						// 					that.lock = false;
						// 					return;
						// 				}
						$
								.ajax({
									url : '${pageContext.request.contextPath}/insertPropertyServiceType',
									type : "post",
									data : that.item,
									dataType : "json",
									success : function(data) {
										var result = data['result'];
										if (result == 1) {
											layer.msg('操作成功!', {
												icon : 1,
												time : 800
											});
											setTimeout(function() {
												parent.query();
												parent.layer.close(that.index);
											}, 1000);
										} else {
											layer.msg('操作失败!', {
												icon : 2,
												time : 800
											});
											that.lock = false;
										}
									}
								});
					}
				}
			})

	$(function() {
		vm.initData();
	});

	function insert() {
		if (!vm.lock) {
			vm.insertPersonnel();
		}
	}
</script>
</html>
